package com.engine.qz.controller;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.qz.service.KqDevService;
import com.engine.qz.service.MeritsService;
import com.engine.qz.service.impl.KqDevServiceImpl;
import com.engine.qz.service.impl.MeritsServiceImpl;
import com.google.gson.Gson;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;

/**
 * @version 1.0
 * @Title ecology-9
 * @Company 泛微软件
 * @CreateDate 2024/11/4
 * @Description 绩效
 * @Author AdminZm
 */
public class MeritsController {

    public MeritsService getMeritsService(User user) {
        return ServiceUtil.getService(MeritsServiceImpl.class,user);
    }


    /**
     * 生成员工指标明细
     */
    @POST
    @Path("/generateIndexDt")
    @Produces(MediaType.APPLICATION_JSON)
    public String generateIndexDt(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).generateIndexDt(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 指标建议值计算
     */
    @POST
    @Path("/countIndexJyz")
    @Produces(MediaType.APPLICATION_JSON)
    public String countIndexJyz(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).countIndexJyz(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 指标计分计算
     */
    @POST
    @Path("/countIndexScoring")
    @Produces(MediaType.APPLICATION_JSON)
    public String countIndexScoring(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).countIndexScoring(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 完成值结果计算
     */
    @POST
    @Path("/countWcz")
    @Produces(MediaType.APPLICATION_JSON)
    public String countWcz(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).countWcz(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 考核结果强制分布
     */
    @POST
    @Path("/distributeCount")
    @Produces(MediaType.APPLICATION_JSON)
    public String distributeCount(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).distributeCount(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 绩效系数排名计算
     */
    @POST
    @Path("/jxxsRankCount")
    @Produces(MediaType.APPLICATION_JSON)
    public String jxxsRankCount(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).jxxsRankCount(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 季度升级计算
     */
    @POST
    @Path("/jdUpgradeCount")
    @Produces(MediaType.APPLICATION_JSON)
    public String jdUpgradeCount(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).jdUpgradeCount(params);
        return  new Gson().toJson(resultDatas);
    }

    /**
     * 人事系统自有数据计算
     */
    @POST
    @Path("/hrmOwnDataCount")
    @Produces(MediaType.APPLICATION_JSON)
    public String hrmOwnDataCount(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        User user = HrmUserVarify.getUser(request, response);
        Map<String, Object> params = ParamUtil.request2Map(request);
        Map<String, Object> resultDatas = getMeritsService(user).hrmOwnDataCount(params);
        return  new Gson().toJson(resultDatas);
    }
}
